<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;



//后台模块表
class UserWalletLogModel extends Model
{
    //定义一个表名
    protected $table = 'user_wallet_log';
    //定义主键
	protected $primaryKey = 'id';
	protected $guarded = [];

	public function add_log($uid = '', $num = 0, $sign = '', $msg = '', $befor = '',  $after = 0, $type = 0, $status = 1,$dy_table = '', $dy_id = 0)
	{
		$this->uid = $uid;
		$this->num = $num;
		$this->sign = $sign;
		$this->msg = $msg;
		$this->befor = $befor;
		$this->after = $after;
		$this->type = $type;
		$this->status = $status;
		$this->dy_table = $dy_table;
		$this->dy_id = $dy_id;
		$this->save();
	}

	function getTypeNameAttribute($value)
	{
		$type = ['1'=>'现金','2'=>'货款','3'=>'股票'];
		return $type[$this->type];
	}
	function getUserNameAttribute($value)
	{
		return UserModel::where('id',$this->uid)->value('user')?UserModel::where('id',$this->uid)->value('user'):'无';
	}
	function getStatusNameAttribute($value)
	{
		$type = ['1'=>'系统','2'=>'提现','3'=>'转货款','4'=>'开通VIP','5'=>'销售奖','6'=>'领导奖','7'=>'教育奖','8'=>'云仓库收益','10'=>'入库','11'=>'购买','12'=>"创客奖",'13'=>'退还388','14'=>'返还VIP押金','15'=>'下单返利','16'=>'拼团下单','17'=>'赠送股票','18'=>'返还本金','19'=>'赠送现金'];
		return $type[$this->status];
	}

 
}
